/**
 * 
 */
package ro.dta.idbi;

import javax.swing.JFrame;
import javax.swing.SwingUtilities;

import ro.dta.idbi.ui.DefaultGUIFactory;
import ro.dta.idbi.ui.MainFrame;
import uk.ac.bbk.dcs.automed.wrappers.MySQLWrapper;
import uk.ac.ic.doc.automed.NotFoundException;
import uk.ac.ic.doc.automed.wrappers.AutoMedWrapper;
import uk.ac.ic.doc.automed.wrappers.PostgresWrapper;

/**
 * Main application class, responsible with starting the application
 * 
 * @author Tudor Dobrila
 */
public final class RunApplication {

	/**
	 * @param args
	 *            Arguments passed to the application
	 * @throws NotFoundException
	 */
	public static void main(final String[] args) throws NotFoundException {
		configureAutoMed();

		final MainFrame frame = new MainFrame(new DefaultGUIFactory(),
				"Interactive Database Integration Tool");
		frame.setVisible(true);
		frame.setSize(1024, 768);
		frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
		
		SwingUtilities.invokeLater(new Runnable() {
			
			@Override
			public void run() {
				frame.getContentPane().requestFocusInWindow();
			}
		});
	}

	/**
	 * Configure the AutoMed library<br />
	 * Register drivers / wrappers
	 */
	public static void configureAutoMed() {
		AutoMedWrapper.registerWrapper(PostgresWrapper.class, null, "org.postgresql.Driver", null);
		AutoMedWrapper.registerWrapper(MySQLWrapper.class, null, "com.mysql.jdbc.Driver", null);
	}

	/**
	 * Private constructor to avoid instantiating this class
	 */
	private RunApplication() {
	}

}
